﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Vav.Data.MySQL;
namespace CarPool.Data.Models
{
    public partial class VavdbContext : DbContext
    {
        private readonly VavdbDataOptions vavdbDataOptions;
        public VavdbContext(VavdbDataOptions vavdbDataOptions)
        {
            this.vavdbDataOptions = vavdbDataOptions;
        }

        public VavdbContext(DbContextOptions<VavdbContext> options)
            : base(options)
        {
        }

        public virtual DbSet<SysCarpool> SysCarpool { get; set; }
        public virtual DbSet<SysUser> SysUser { get; set; }
        public virtual DbSet<WechatInfo> WechatInfo { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseMySql(vavdbDataOptions.ConnectionString);
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<SysCarpool>(entity =>
            {
                entity.ToTable("sys_carpool");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.ArriveAddress)
                    .HasColumnName("arrive_address")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.ArriveLatitude).HasColumnName("arrive_latitude");

                entity.Property(e => e.ArriveLongitude).HasColumnName("arrive_longitude");

                entity.Property(e => e.ArrivePlace)
                    .HasColumnName("arrive_place")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("'CURRENT_TIMESTAMP'");

                entity.Property(e => e.DataStatus)
                    .HasColumnName("data_status")
                    .HasColumnType("int(11)")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.LeaveAddress)
                    .HasColumnName("leave_address")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.LeaveLatitude).HasColumnName("leave_latitude");

                entity.Property(e => e.LeaveLongitude).HasColumnName("leave_longitude");

                entity.Property(e => e.LeavePlace)
                    .HasColumnName("leave_place")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.LeaveTime)
                    .HasColumnName("leave_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.Person)
                    .HasColumnName("person")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Price)
                   .HasColumnName("price")
                   .HasColumnType("decimal(10,2)");

                entity.Property(e => e.ContactName)
                    .HasColumnName("contact_name")
                    .HasColumnType("varchar(11)");

                entity.Property(e => e.Phone)
                   .HasColumnName("phone")
                   .HasColumnType("varchar(50)");

                entity.Property(e => e.Remark)
                    .HasColumnName("remark")
                    .HasColumnType("varchar(255)");

                entity.Property(e => e.State)
                    .HasColumnName("state")
                    .HasColumnType("int(11)")
                    .HasDefaultValueSql("'1'");

                entity.Property(e => e.Type)
                    .HasColumnName("type")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("int(11)");

                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("'CURRENT_TIMESTAMP'")
                    .ValueGeneratedOnAddOrUpdate();
            });

            modelBuilder.Entity<SysUser>(entity =>
            {
                entity.ToTable("sys_user");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("'CURRENT_TIMESTAMP'");

                entity.Property(e => e.DataStatus)
                    .HasColumnName("data_status")
                    .HasColumnType("int(11)")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.Gender)
                    .HasColumnName("gender")
                    .HasColumnType("int(11)")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.HeadPic)
                    .HasColumnName("head_pic")
                    .HasColumnType("varchar(100)")
                    .HasDefaultValueSql("''");

                entity.Property(e => e.NickName)
                    .HasColumnName("nick_name")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.Phone)
                    .HasColumnName("phone")
                    .HasColumnType("varchar(20)");

                entity.Property(e => e.State)
                    .HasColumnName("state")
                    .HasColumnType("int(11)")
                    .HasDefaultValueSql("'1'");

                entity.Property(e => e.UnionId)
                    .HasColumnName("union_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("'CURRENT_TIMESTAMP'")
                    .ValueGeneratedOnAddOrUpdate();
            });

            modelBuilder.Entity<WechatInfo>(entity =>
            {
                entity.ToTable("wechat_info");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.AccessToken)
                    .HasColumnName("access_token")
                    .HasColumnType("varchar(512)");

                entity.Property(e => e.Appid)
                    .HasColumnName("appid")
                    .HasColumnType("varchar(255)");

                entity.Property(e => e.Appname)
                    .HasColumnName("appname")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.Appsecret)
                    .HasColumnName("appsecret")
                    .HasColumnType("varchar(255)");

                entity.Property(e => e.Createtime)
                    .HasColumnName("createtime")
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("'CURRENT_TIMESTAMP'");

                entity.Property(e => e.Expirestime)
                    .HasColumnName("expirestime")
                    .HasColumnType("datetime");

                entity.Property(e => e.MchId)
                    .HasColumnName("mch_id")
                    .HasColumnType("varchar(255)");

                entity.Property(e => e.Type)
                    .HasColumnName("type")
                    .HasColumnType("int(11)");
            });
        }
    }
}
